package edu.bit.water.controller;

import edu.bit.water.entity.MetaDischargeMaxPermission;
import edu.bit.water.entity.WasteWaterEva;
import edu.bit.water.entity.WasteWaterEva2;
import edu.bit.water.entity.WasteWaterNewSub1;
import edu.bit.water.service.MetaDischargeService;
import edu.bit.water.service.WasteWaterNewSub1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/waste_water_newsub1")
public class WasteWaterNewSub1Controller {

    @Autowired
    private WasteWaterNewSub1Service wasteWaterNewSub1Service;

    @ResponseBody
    @RequestMapping(value = "/select", method=RequestMethod.GET)
    public Map<String, Object> queryWasteWaterNewSub1(int lastId) {
        //System.out.println("-------------------------------------------------------");
        //System.out.println(last_id);
        //System.out.println("-------------------------------------------------------");
        Map<String, Object> result = new HashMap<>();
        List<WasteWaterNewSub1> list = wasteWaterNewSub1Service.queryWasteWaterNewSub1(lastId);
        result.put("rows", list);
        return result;
    }

    @ResponseBody
    @RequestMapping("/insert")
    public Map<String, Object> inserWasteWaterNewSub1(WasteWaterNewSub1 wasteWaterNewSub1) {
        //metaDischarge.showContent();
        Map<String, Object> result = wasteWaterNewSub1Service.insertWasteWaterNewSub1(wasteWaterNewSub1);
        return result;
    }

    /**
     * 删除metaDischarge
     * author Page
     */
    @ResponseBody
    @RequestMapping("/delete")
    public Map<String, Object> deleteWasteWaterNewSub1(@RequestBody List<String> WasteWaterNewSub1) {
        return wasteWaterNewSub1Service.deleteWasteWaterNewSub1(WasteWaterNewSub1);
    }

    @ResponseBody
    @RequestMapping("/update")
    public Map<String, Object> updateWasteWaterNewSub1(WasteWaterNewSub1 wasteWaterNewSub1) {
        Map<String, Object> result = wasteWaterNewSub1Service.updateWasteWaterNewSub1(wasteWaterNewSub1);
        return result;
    }

    @RequestMapping("/getNewWaste")
    @ResponseBody
    public Map<String, Object> getScope(){
        Map<String, Object> modelMap = new HashMap<>();
        List<MetaDischargeMaxPermission> list = wasteWaterNewSub1Service.getWaste();
        modelMap.put("status", "success");
        modelMap.put("rows", list);
        return modelMap;
    }

    @RequestMapping("/label_update")
    @ResponseBody
    public Map<String, String> labelUpdate(WasteWaterEva2 wasteWaterEva2){
        return wasteWaterNewSub1Service.labelUpdate(wasteWaterEva2);
    }
}
